package com.zzr.demo.redis.controller;

import com.zzr.demo.redis.model.Person;
import com.zzr.demo.redis.service.PreViewService;
import com.zzr.demo.redis.service.impl.StringPreViewServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: xiaomi
 * @date: 2021/10/7
 * @description:
 */
@RestController()
@RequestMapping("preView/string")
@Api(tags = "预览：大字符串")
@Slf4j
public class StringPreViewController {

    @Autowired
    PreViewService preViewService;

    @GetMapping("/size/{key}")
    @ApiOperation("获取长度")
    public Long size(@PathVariable("key") String key) {
        Long count = preViewService.getCount(key);
        return count;
    }

    @GetMapping("/preView/{key}/{index}")
    @ApiOperation("获取预览数据")
    public String getPreView(@PathVariable("key") String key, @PathVariable("index") Long index) {
        String preView = preViewService.getPreView(key, index);
        return preView;
    }
}
